<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="cn.sqlexperiment.web.classes.doctorname" %>
<%@ page import="java.util.ArrayList" %><%--
  Created by IntelliJ IDEA.
  User: jizhaoyang
  Date: 2023/12/7
  Time: 下午 4:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        a:link,
        a:hover,
        a:visited,
        a:active {
            color: #fff;
            text-decoration: none;
        }

        body {
            height: 100%;
            width: 100%;
            margin: 0;
            padding: 0;
            background: #fff;
        }

        .card-holder {
            position: fixed;
            width: 0px;
            overflow: visible;
        }

        .card-wrapper {
            display: inline-block;
            float: right;
            clear: both;
        }

        .card {
            position: relative;
            left: 32px;
            padding: 16px 32px 16px 64px;
            margin: 8px;
            background: #fff;
            transition: all 0.3s ease-in-out 0.1s;
        }

        /*//添加导航的响应式效果*/
        .card:hover {
            position: relative;
            left: 100%;
            margin-left: -32px;
            transition: all 0.3s ease-in-out;
        }

        .card-content {
            display: inline-block;
            color: #fff;
            font-family: 'Droid Sans', sans-serif;
            font-size: 16px;
            font-weight: bold;
            white-space: nowrap;
        }

        .bg-01 { background: #539770; }
        .bg-02 { background: #4B7D74; }
        .bg-03 { background: #8DC2BC; }
        .bg-04 { background: #EDD6B4; }
        .bg-05 { background: #BE7467; }
        .bg-06 { background: #E2AE63; }

        .box{
            width: 1000px;
            /* 超出部分隐藏 */
            overflow: hidden;
            margin: auto;
            display: flex;
            background-color: #8DC2BC;
        }
        .content{
            width: 1000px;
            height: 600px;
            flex-shrink: 0;
        }

        h2{
            line-height: 40px;
            text-align: center;
        }
        input[type="submit"]{
            /* 设置宽高 */
            width: 110px;
            height: 40px;

            /* 内部文本居中 */
            text-align: center;

            /* 圆角边框 */
            border-radius: 5px;

            /* 设置字体 */
            font:16px "黑体";

            /* 设置背景颜色 */
            background-color: #C0C6CB;

            text-align: center;
        }

        .textinput{
            /* 设置宽高 */
            height: 40px;
            width: 300px;

            /* 设置内边距 */
            padding: 0 35px;

            /* 去除边框 */
            border: none;

            /* 设置背景颜色 */
            background: #F8F9F9;

            /* 设置字体大小 */
            font-size: 15px;

            /* 给文本框加上阴影 */
            box-shadow: 0px 1px 1px rgba(255, 255, 255, 0.7), inset 0px 2px 5px #aaaaaa;

            /* 给文本框加上圆角边框 */
            border-radius: 5px;

            /* 给文本框中输入文字加上颜色 */
            color: saddlebrown;

        }
        .patiname{
            font-size: 20px;
            text-align: center;
        }
        .cintenttext{
            text-align: center;
            line-height: 500px;
            font-size: 30px;
            font-family: 'Droid Sans', sans-serif;
        }
    </style>
</head>

<body>
<jsp:useBean id="doctorname1" class="cn.sqlexperiment.web.classes.doctorname" scope="request"></jsp:useBean>
<%
    Class.forName("com.mysql.jdbc.Driver");
    String url = "jdbc:mysql://localhost:3306/hospital";
    String name = "root";
    String password = "12345";
    request.setCharacterEncoding("UTF-8");
    Connection conn = DriverManager.getConnection(url, name, password);
    doctorname dn = (doctorname)request.getAttribute("doctorname1");
    String docno=dn.getPno();
    String sql = "SELECT patient.* FROM patient WHERE  chief_no= ?";
    PreparedStatement stmt = conn.prepareStatement(sql);
    stmt.setString(1, docno);
    ResultSet rs = stmt.executeQuery();
    String pati_name = new String();
    String pati_no = new String();
    ArrayList<String> patinamearray=new ArrayList<>();
    ArrayList<String> patinoarray=new ArrayList<>();
    int i = 0;
    while (rs.next()) {
        pati_name = rs.getString("pati_name");
        pati_no = rs.getString("pati_no");
        patinamearray.add(pati_name);
        patinoarray.add(pati_no);
    }
    sql = "SELECT ward.* FROM ward WHERE ward_sect_no = \n" +
            "(SELECT section.sect_no\n" +
            "FROM section\n" +
            "WHERE sect_no=(SELECT doctor.doc_sect_no FROM doctor WHERE doc_no=?))";
    stmt = conn.prepareStatement(sql);
    stmt.setString(1, docno);
    rs = stmt.executeQuery();
    String ward_no=new String();
    ArrayList<String> wardnoarray=new ArrayList<>();
    while (rs.next()) {
        ward_no = rs.getString("ward_no");
        wardnoarray.add(ward_no);
    }
    rs.close();
    stmt.close();
    conn.close();
%>

<h2><strong><jsp:getProperty name="doctorname1" property="name"/>医生界面</strong></h2>
<br>
<div class='card-holder'>
    <div class='card-wrapper'>
        <a href='#'>
            <div class='card bg-01'>
                <span class='card-content'><a href="#content1" id="nav1">查询病历</a></span>
            </div>
        </a>
    </div>
    <div class='card-wrapper'>
        <a href='#'>
            <div class='card bg-04'>
                <span class='card-content'><a href="#content4" id="nav3">查询收治患者信息</a></span>
            </div>
        </a>
    </div>
    <div class='card-wrapper'>
        <a href='#'>
            <div class='card bg-05'>
                <span class='card-content'><a href="#content5" id="nav4">查询查房结果</a></span>
            </div>
        </a>
    </div>
    <div class='card-wrapper'>
        <a href='#'>
            <div class='card bg-06'>
                <span class='card-content'><a href="#content3" id="nav5">登记出院</a></span>
            </div>
        </a>
    </div>
</div>

<section>
    <div class="box">
        <div id="content0" class="content"><p class="cintenttext">欢迎使用医院住院管理系统</p>
        </div>
        <div id="content1" class="content">
            <form action="/_war_exploded/ShowCaseServlet" method="post">
                <input type="text" class="textinput" style="display: none" name="docno" value="<jsp:getProperty name="doctorname1" property="pno"/>"/>
            <p class="patiname">请输入患者姓名：
                <select class="textinput" name="Patiname">
                    <%
                        for(i=0;i<patinamearray.size();i++){
                    %>
                    <option><%=patinamearray.get(i)%></option>
                    <%
                        }
                    %>
                </select><br /><br>
                <input type="submit" value="查询病历" />
            </p>
            </form>
        </div>
        <div id="content3" class="content">
            <form action="/_war_exploded/OutHospitalServlet" method="post">
                <p class="patiname">请输入患者姓名：
                    <select class="textinput" name="Patiname">
                        <%
                            for(i=0;i<patinamearray.size();i++){
                        %>
                        <option><%=(patinamearray.get(i)+" "+patinoarray.get(i))%></option>
                        <%
                            }
                        %>
                    </select><br /><br>
                    <input type="submit" value="登记出院" />
            </form>
        </div>
        <div id="content4" class="content">
            <form action="showpatient.jsp" method="post">
                <input type="text" class="textinput" style="display: none" name="docno" value="<jsp:getProperty name="doctorname1" property="pno"/>"/>
                <p class="patiname">请输入患者姓名<br /><br>
                    <select class="textinput" name="Patiname">
                        <%
                            for(i=0;i<patinamearray.size();i++){
                        %>
                        <option><%=patinamearray.get(i)%></option>
                        <%
                            }
                        %>
                    </select><br /><br>
                    <input type="submit" value="查询患者信息" />
                </p>
            </form>
        </div>
        <div id="content5" class="content">
            <form action="showround.jsp" method="post">
                <p class="patiname">请输入病房号<br/>
                    <select class="textinput" name="wardno">
                        <%
                            for(i=0;i<wardnoarray.size();i++){
                        %>
                        <option><%=wardnoarray.get(i)%></option>
                        <%
                            }
                        %>
                    </select><br /><br>
                    <input type="submit" value="查询查房结果" />
                </p>
            </form>
        </div>
    </div>
</section>

</body>
</html>